package com.haoze.nurseapp.enumeration;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum ElementVarForSpecialEnum {
    SYZX_SPEED("syzx_speed","滴速"),
    SY_SYL("sy_syl","剩余量");

    private String varCode;
    private String name;


    ElementVarForSpecialEnum(String varCode, String name){
        this.varCode = varCode;
        this.name = name;
    }

    public static ElementVarForSpecialEnum getId(String varCode){
        if(StringUtils.isEmpty(varCode)) return null;
        List<ElementVarForSpecialEnum> list = Arrays.stream(ElementVarForSpecialEnum.values()).filter(x -> x.getVarCode().equals(varCode)).collect(Collectors.toList());
        if(!CollectionUtils.isEmpty(list)){
            return list.get(0);
        }
        return null;
    }

    public String getVarCode() {
        return varCode;
    }

    public String getName() {
        return name;
    }
}
